/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SeleniumTest;

import com.thoughtworks.selenium.SeleneseTestCase;
import java.util.regex.Pattern;

/**
 *
 * @author User
 */
public class FriendsSeleneseTest extends SeleneseTestCase {

    @Override
	public void setUp() throws Exception {
            super.setUp("http://localhost:8080/","*firefox");
            selenium.setSpeed("2000"); //increase this for tests performed on slower connections
	}

        //tests that User can add to their list
        public void testAddFriends() throws Exception {
               selenium.open("/GooWhere/");
		selenium.type("username", "Rodge");
		selenium.type("password", "testpassword2");
		selenium.click("btn_login2");
		selenium.waitForPageToLoad("30000");
		selenium.click("//img[@id='menu_account']");
		selenium.click("btn_friends");
		verifyTrue(selenium.isTextPresent("Clara"));
		selenium.click("btn_rank");
		selenium.click("//table[2]/tr/td/div/div[7]/a/img");
		selenium.click("//table[4]/tr/td/div/div[8]/a/img");
		selenium.click("btn_friends");
		verifyTrue(selenium.isTextPresent("Erico"));
		verifyTrue(selenium.isTextPresent("Clara"));
		verifyTrue(selenium.isTextPresent("Aboard"));
		selenium.click("account _close");
		selenium.click("//img[@id='menu_game_logout']");
		selenium.click("ok_button");
		selenium.waitForPageToLoad("30000");
		selenium.type("username", "Rodge");
		selenium.type("password", "testpassword2");
		selenium.click("btn_login2");
		selenium.waitForPageToLoad("30000");
		selenium.click("//img[@id='menu_account']");
		selenium.click("btn_friends");
		verifyTrue(selenium.isTextPresent("Erico"));
		verifyTrue(selenium.isTextPresent("Clara"));
		verifyTrue(selenium.isTextPresent("Aboard"));
		selenium.click("account _close");
		selenium.click("//img[@id='menu_game_logout']");
		selenium.click("ok_button");
		selenium.waitForPageToLoad("30000");
	}

        //tests that User can remove users from their list
        public void testRemoveFriends() throws Exception {
                selenium.open("/GooWhere/");
		selenium.type("username", "Rodge");
		selenium.type("password", "testpassword2");
		selenium.click("btn_login2");
		selenium.waitForPageToLoad("30000");
		selenium.click("//img[@id='menu_account']");
		selenium.click("btn_friends");
		verifyTrue(selenium.isTextPresent("Erico"));
		verifyTrue(selenium.isTextPresent("Clara"));
		verifyTrue(selenium.isTextPresent("Aboard"));
		selenium.click("btn_remove2");
		selenium.click("//div[9]/a/img");
		verifyTrue(selenium.isTextPresent("Clara"));
		selenium.click("account _close");
		selenium.click("//img[@id='menu_game_logout']");
		selenium.click("ok_button");
		selenium.waitForPageToLoad("30000");
		selenium.type("username", "Rodge");
		selenium.type("password", "testpassword2");
		selenium.click("btn_login2");
		selenium.waitForPageToLoad("30000");
		selenium.click("//img[@id='menu_account']");
		selenium.click("btn_friends");
		verifyTrue(selenium.isTextPresent("Clara"));
		selenium.click("account _close");
		selenium.click("//img[@id='menu_game_logout']");
		selenium.click("ok_button");
		selenium.waitForPageToLoad("30000");
	}

        
        //tests that User can view their Friends List, add and remove users from their list in the same session
        public void testAddRemoveFriends() throws Exception {
                selenium.open("/GooWhere/");
		selenium.type("username", "Rodge");
		selenium.type("password", "testpassword2");
		selenium.click("btn_login2");
		selenium.click("//img[@id='menu_account']");
		selenium.click("btn_friends");
		verifyTrue(selenium.isTextPresent("Clara"));
		selenium.click("account_r2_c1");
		selenium.click("btn_rank");
		selenium.click("//table[9]/tr/td/div/div[8]/a/img");
		selenium.click("//table[10]/tr/td/div/div[7]/a/img");
		selenium.click("btn_friends");
		verifyTrue(selenium.isTextPresent("Clara"));
		verifyTrue(selenium.isTextPresent("Mario"));
		verifyTrue(selenium.isTextPresent("l33thacker"));
		selenium.click("account _close");
		selenium.click("//img[@id='clue_control']");
		selenium.click("//img[@id='clue_control']");
		selenium.click("//img[@id='clue_control']");
		selenium.click("clue_window_cancel");
		selenium.click("go_east");
		selenium.click("go_east");
		selenium.click("go_east");
		selenium.click("//div[@id='loading_window_bg']/table");
		selenium.click("trans_bus_data_fourth");
		selenium.click("//img[@id='menu_account']");
		verifyTrue(selenium.isTextPresent("Clara"));
		verifyTrue(selenium.isTextPresent("Mario"));
		verifyTrue(selenium.isTextPresent("l33thacker"));
		selenium.click("//div[9]/a/img");
		selenium.click("account _close");
		selenium.click("//img[@id='menu_account']");
		selenium.click("//table[2]/tr/td/div/div[10]/a/img");
		verifyTrue(selenium.isTextPresent("Clara"));
		selenium.click("account _close");
		selenium.click("//img[@id='menu_game_logout']");
		selenium.click("ok_button");
		selenium.waitForPageToLoad("30000");

	}


}
